﻿using MySql.Data.MySqlClient;
using NB.MGJ.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NB.MGJ.Service
{
    /// <summary>
    /// Demo演示
    /// </summary>
    /// =======================================================================
    /// 类名：DemoService DemoController的备注：DemoService~1<br/>
    /// =======================================================================<br/>
    /// 更新履历<br/>
    /// 序号          更新日期          责任人           更新内容<br/>
    /// 001           2017/8/16        陈峰             新建<br/>
    /// =======================================================================<br/>
    public partial class DemoService
    {
        #region 用户管理
        /// <summary>
        /// 用户管理
        /// </summary>
        /// <param name="pager"></param>
        /// <returns></returns>
        public string GetUserInfoListService()
        { return ""; }
        /// <summary>
        /// 编辑用户
        /// </summary>
        public void EditUserService() 
        { }
        /// <summary>
        /// 新增用户
        /// </summary>
        public void AddUserService()
        { }
        /// <summary>
        /// 删除用户
        /// </summary>
        public void DelUserService() 
        { }
        #endregion

        #region 角色管理
        /// <summary>
        /// 角色管理
        /// </summary>
        /// <param name="pager"></param>
        /// <returns></returns>
        public PagedList<Demo> GetRoleService(ref PagerModel pager)
        {
            StringBuilder strSql1 = new StringBuilder();
            strSql1.Append(@"Demo");

            var strSql = new StringBuilder(strSql1.ToString().Trim(','));
            pager.FldName = " ID,name,TID   ";
            pager.TblName = strSql.ToString();

            if (string.IsNullOrEmpty(pager.StrCondition) || pager.StrCondition == " ")
            {
                pager.StrCondition = "  1=1 ";
            }

            if (string.IsNullOrEmpty(pager.FldSort) || pager.FldSort == "")
                pager.FldSort = "   ID desc ";
            MySqlParameter[] parameters = _baseRepository.SqParameterRefactor(ref pager);
            IEnumerable<Demo> resultList = _baseRepository.ExecuteStoredProcedureCollection<Demo>("Common_PageList", parameters);
            return new PagedList<Demo>(resultList, pager.Page, pager.PageSize, 1, Convert.ToInt32(parameters[6].Value));
        }
        #endregion

        #region 小程序手机端
        
        #endregion
    }
}
